const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const { ANALYZE } = process.env
const webpack = require('webpack')
const isProd = process.env.NODE_ENV === 'production'
require('dotenv').config()
module.exports = {
  assetPrefix: process.env.ASSETS_PREFIX_URL || '',
  
  webpack: function (config) {
    if (ANALYZE) {
      config.plugins.push(new BundleAnalyzerPlugin({
        analyzerMode: 'server',
        analyzerPort: 8888,
        openAnalyzer: true
      }))
    }
    config.plugins.push(
      new webpack.EnvironmentPlugin(['ASSETS_PREFIX_URL', 'STATIC_PREFIX_URL', 'API_SERVER_URL'])
    );

    return config
  }
}